<?php
namespace app\console\service;

use think\console\Input;
use think\console\input\Option;
use think\console\Output;
use app\console\server\TcpServer;

class Server extends \think\console\Command {


    protected function configure() {
        $this->setName('swoole')->addOption('s', NULL, Option::VALUE_REQUIRED, 'start|stop|reload')
            ->setDescription('定时定时轮询服务');
    }

    protected function execute(Input $input, Output $output) {
        $signal = $input->getOption('s');
        switch ($signal) {
            case 'start':
                $tcp_server = new TcpServer();
                $tcp_server->run();
                break;
            case 'stop':
                TcpServer::stop();
                echo '停止';
                break;
            case 'stop':
                TcpServer::reload();
                echo '重启';
                break;
            default:
                break;
        }
    }

}
